/*
 * Copyright (C) 2009 Christoph Caks
 *
 * This file is part of GLWAK.
 *
 * GLWAK is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * GLWAK is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with GLWAK.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 * WindowsWindow.h
 *
 *  Created on: 31.06.2009
 *      Author: Christoph Caks
 */

#ifndef WINDOWSWINDOW_H_
#define WINDOWSWINDOW_H_

#include "Log.h"

#include "Window.h"

#include "windows/WindowsHelper.h"
#include <windows.h>
#include <iostream>

#include "OpenThreads/Thread"

#include "OpenGL.h"
//#include <GL/glx.h>

//#include <X11/Xlib.h>
//#include <X11/Xutil.h>
//#include <X11/extensions/xf86vmode.h>


/*
 * GLX_ARB_create_context
 */
 
 /*
#ifndef GLX_ARB_create_context
#define GLX_ARB_create_context 1

// Accepted as an attribute name in <*attrib_list>
#define GLX_CONTEXT_MAJOR_VERSION_ARB           0x2091
#define GLX_CONTEXT_MINOR_VERSION_ARB           0x2092
#define GLX_CONTEXT_FLAGS_ARB                   0x2094

// Accepted as bits in the attribute value for GLX_CONTEXT_FLAGS in <*attrib_list>
#define GLX_CONTEXT_DEBUG_BIT_ARB               0x0001
#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB  0x0002

extern GLXContext glXCreateContextAttribsARB( Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list );
#endif // GLX_ARB_create_context

typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);

*/

namespace glwak {

namespace priv {

class WindowsWindow: public Window, public OpenThreads::Thread {
public:
	WindowsWindow();
	virtual ~WindowsWindow();

	// from Window
	void hide();
	void show();
	size_t getWindowHandle();

	// from Disposable
	void dispose();

	// own
	HWND getWindow();

	void startMessageLoop();
	void startMessageThread();

private:

	// from Window
	void initializeImpl();
	void reinitializeImpl();

	// from Thread
	void run();

	// own
	HWND window;

	static LRESULT CALLBACK WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );

	void fullscreen();
};

} // namespace priv

} // namespace glwak

#endif /* WINDOWSWINDOW_H_ */
